package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.Utils.Result;
import cn.com.yusys.yusp.admin.domain.GridCustomerAUMAndProductCompositionReportPojo;
import cn.com.yusys.yusp.admin.domain.WcrmMarketActivity;
import cn.com.yusys.yusp.admin.service.WcrmMarketActivityService;
import cn.com.yusys.yusp.commons.excel.ExcelTaskManager;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 营销活动表(WcrmMarketActivity)表控制层
 *
 * @author pig4cloud
 * @since 2021-06-24 10:24:09
 */
@RestController
@RequestMapping("/api/wcrmMarketActivity")
public class WcrmMarketActivityResource {
	/**
	 * 服务对象
	 */
	@Resource
	private WcrmMarketActivityService wcrmMarketActivityService;
	@Resource
	private ExcelTaskManager excelTaskManager;
	private String pojoClassName = WcrmMarketActivity.class.getName();
	private String exportSql = "queryTableData";

	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("selectOne")
	public WcrmMarketActivity selectOne(String id) {
		return this.wcrmMarketActivityService.queryById(id);
	}

	/**
	 * 查询table数据
	 *
	 */
	@GetMapping("/queryTableData")
	public ResultDto<Object> queryTableData(QueryModel queryModel){
		return new ResultDto<>(wcrmMarketActivityService.queryTableData(queryModel));
	}

	/**
	 * 新增营销活动
	 */
	@PostMapping("/saveMarketActivity")
	public ResultDto<Object> saveMarketActivity(@RequestBody Map queryModel){
		return new ResultDto<>(wcrmMarketActivityService.saveMarketActivity(queryModel));
	}

	/**
	 * 分配营销活动
	 */
	@GetMapping("/saveIssus")
	public Result<String> saveMarketActivity(QueryModel queryModel){
		return wcrmMarketActivityService.saveIssus(queryModel);
	}
	@GetMapping("/saveIssusMgr")
	public Result<String> saveMgrMarketActivity(QueryModel queryModel){
		return wcrmMarketActivityService.saveIssusMgr(queryModel);
	}

	/**
	 * 逻辑批量删除营销活动信息
	 */
	@DeleteMapping("/delete")
	public Result<String> deletebatch(@RequestParam String ids) {
		return wcrmMarketActivityService.deletebatch(ids);
	}


	@GetMapping("/exportExcel")
	public ResultDto<String> exportExcel(QueryModel queryModel){
		CustCenterResource.judgeUserJurisdiction(queryModel, true);
		String taskId = excelTaskManager.addExcelExportTask(exportSql, null, queryModel, pojoClassName);
		return new ResultDto<>(taskId);
	}

}